"""
@author: tian-yan-tian-ge
@file: 练习7.py
@time: 2023/12/12 22:30
"""
# 7、定义一个字典，value都为整数类型。输出字典中value的最大值以及它的key，输出字典中value的平均值
# 定义字典
dictionary = {
    "key1": 10,
    "key2": 20,
    "key3": 30,
    "key4": 40,
    "key5": 50,
}

# 找到value的最大值以及它的key
max_value = max(dictionary.values())
max_key = [key for key, value in dictionary.items() if value == max_value]

# 输出最大值和它的key
print(f"最大值: {max_value}")
print(f"对应的key: {max_key[0]}")

# 计算value的平均值
average_value = sum(dictionary.values()) / len(dictionary)

# 输出平均值
print(f"平均值: {average_value}")